Relational Database Design and Modeling for Software Engineers
Rate this course
Ask Author
Contribute
Back to course home

0% completed

Vote For New Content
Introduction
Course Overview
Before the Advent of Database
Fundamental Concepts
What is a Database?
Database management systems (DBMS)
Overview of Relational Databases
Relational Vs. Non-Relational Databases
Data Modeling
Introduction to Data Modeling
Levels of Data Modeling
Data Modeling Process
Best Practices in Data Modeling
Quiz
Entity-Relationship (ER) Data Modeling
Introduction to ER Models
Entities, Attributes, and Relationships
Cardinality and Participation
Attributes of Relationship Types
Weak Entity Types
Creating an ER Diagram for Employee Management System
Quiz
The Relational Data Model
Introduction to the Relational Model
Relations, Tuples, and Attributes
Keys in Relational Databases
Relational Integrity Constraints
Converting ER Diagrams to Relational Model
Best Practices for ER Diagrams to Relational Models
Quiz
Functional Dependency
Introduction to Functional Dependency
Types of Functional Dependencies
Inference Rules for Functional Dependencies
Closure of Attribute Sets
Quiz
Normalization
Introduction to Normalization
First Normal Form (1NF)
Second Normal Form (2NF)
Third Normal Form (3NF)
Boyce-Codd Normal Form (BCNF)
Higher Normal Forms (4NF, 5NF)
Exercise 1
Solution to Exercise 1
Exercise 2
Solution to Exercise 2
Designing a Hospital Management System
Designing a Hotel Management System
Designing a Bank Management System
Designing an Instagram
Designing an E-commerce Platform
Designing an Online Food Delivery System
Solution to Exercise 1

Analysis

Step 1: Identify the Primary Key

  • The table's primary key is a composite key consisting of {Employee_ID, Project_ID} because:

    • An Employee can work on multiple Projects.
    • A Project can have multiple Employees working on it.

Step 2: Check for Partial Dependencies

  • Partial Dependency occurs when a non-key attribute depends only on a part of the composite primary key.

  • Identify Dependencies:

    1. Employee_Name depends only on Employee_ID.
    2. Project_Name and Project_Manager depend only on Project_ID.
  • Final Result:

    • Since some non-key attributes depend only on a part of the composite primary key, the table is not in 2NF.

Conversion to Second Normal Form (2NF)

To achieve 2NF, we need to remove partial dependencies by creating separate tables for each entity.

Step 1: Create the Employee Table

This table stores information specific to each employee.

Employee Table

Employee_ID (PK)Employee_Name
101Alice
102Bob
103Charlie
  • Primary Key: Employee_ID

  • Explanation:

    • Employee_Name is fully functionally dependent on Employee_ID.
    • This table contains no partial dependencies.

Step 2: Create the Project Table

This table stores information specific to each project.

Project Table

Project_ID (PK)Project_NameProject_Manager
P1AlphaJohn
P2BetaSarah
P3GammaAlice
  • Primary Key: Project_ID

  • Explanation:

    • Project_Name and Project_Manager are fully functionally dependent on Project_ID.
    • This table eliminates partial dependencies related to projects.

Step 3: Create the Employee_Project Table

This table links employees to the projects they are working on.

Employee_Project Table

Employee_ID (PK)(FK)Project_ID (PK)(FK)
101P1
101P2
102P1
103P3
  • Composite Primary Key: {Employee_ID, Project_ID}

  • Foreign Keys:

    • Employee_ID references the Employee table.
    • Project_ID references the Project table.
  • Explanation:

    • This table represents the many-to-many relationship between employees and projects.
    • There are no non-key attributes, so no partial dependencies exist.

Final Result

By decomposing the original table into three tables, we have:

  • Eliminated Partial Dependencies:

    • Each non-key attribute is now fully dependent on the primary key of its respective table.
  • Achieved Second Normal Form (2NF):

    • All tables are in 1NF and have no partial dependencies.
Exercise 1
Exercise 2
Mark as Completed

On this page

Analysis

Step 1: Identify the Primary Key

Step 2: Check for Partial Dependencies

Conversion to Second Normal Form (2NF)

Step 1: Create the Employee Table

Step 2: Create the Project Table

Final Result